package org.dftproject.lineagelinkage.ui.pages;

import org.dftproject.genesis.ui.figures.TooltipLabel;
import org.dftproject.lineagelinkage.ui.Activator;
import org.eclipse.draw2d.Figure;
import org.eclipse.draw2d.ImageFigure;
import org.eclipse.draw2d.MouseEvent;
import org.eclipse.draw2d.MouseListener;
import org.eclipse.draw2d.ToolbarLayout;

public class RatingFigure extends Figure {
	
	public RatingFigure(int stars) {
		ToolbarLayout layout = new ToolbarLayout(true);
		layout.setSpacing(2);
		setLayoutManager(layout);
		
		for (int i = 0; i < stars; i++) {
			ImageFigure star = new ImageFigure(Activator.getImageDescriptor("icons/star.png").createImage());
			add(star);
		}
		
		setToolTip(new TooltipLabel(getTooltipText(stars)));
		
		addMouseListener(new MouseListener.Stub() {

			@Override
			public void mousePressed(MouseEvent me) {
				me.consume();
			}

		});
	}

	protected String getTooltipText(int stars) {
		switch (stars) {
		case 1:
			return "Probably not a match";
		case 2:
			return "Possibly a match";
		case 3:
			return "Likely a match";
		case 4:
			return "High probability of a match";
		case 5:
			return "Very high probability of a match";
		}
		return null;
	}

}
